package com.onejson.ojmall.controller;

import cn.hutool.extra.servlet.ServletUtil;
import com.onejson.ojmall.common.domain.ResponseDTO;
import com.onejson.ojmall.entity.form.LoginForm;
import com.onejson.ojmall.entity.vo.LoginResultVO;
import com.onejson.ojmall.service.impl.LoginService;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 登录
 *
 */
@RestController
public class LoginController {

    @Resource
    private LoginService loginService;

    @PostMapping("/login")
    @Operation(summary = "登录")
    public ResponseDTO<LoginResultVO> login(@RequestBody LoginForm loginForm, HttpServletRequest request) {
        String ip = ServletUtil.getClientIP(request);
        return loginService.login(loginForm, ip);
    }

}
